package field_REGEX_Definitions.IFAfields;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import field_REGEX_Definitions.Field;
import fields.*;

public class Card_Number implements Field{
	private Pattern collection_date = Pattern.compile("card[\\n\\s]*number[\\n\\s:]*[\\n\\s]*(\\d{1,4}[\\n\\s]*" +
			"\\d{1,4}[\\s]*\\d{1,4}[\\s]*\\d{1,4}[\\s]*)",Pattern.CASE_INSENSITIVE);
	private String field;
	private String type = "IFA";
	
	public boolean matches(String input) {
		Matcher matcher = collection_date.matcher(input);
		boolean result = matcher.find();
		if (result) {
			field = "Card Number";
		}
		return result;
	}
	
	public String getFieldName(){
		return field;
	}

	public CreditCard execute() {
		return new CreditCard(field,"IFA");
	}
	
	public String getFieldType() {
		return type;
	}
}
